home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5494 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  45 lines

  1. Path: news.halcyon.com!usenet
  2. From: normanb@halcyon.com (Norm Bryar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: generic paramter to template question
  5. Date: Sun, 04 Feb 1996 23:34:04 GMT
  6. Organization: Northwest Nexus Inc.
  7. Message-ID: <4f3foh$7nq@news.halcyon.com>
  8. References: <4eumei$j82@qualcomm.com>
  9. NNTP-Posting-Host: blv-pm11-ip19.halcyon.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. nabbasi@qualcomm.com (Nasser Abbasi) wrote:
  13.  
  14. >hi,
  15.  
  16. >How can one give a template a parameter that is a value of generic type?
  17.  
  18. >A template can take as paramter as a type, and also it can take a 
  19. >parameter that is a variable of known type as in:
  20.  
  21. >template<class T,int item> class foo{..}
  22.  
  23. >but in the above the type of "item" is not generic. is there a way 
  24. >to pass "item" above but let the user have its type as generic also (as 
  25. >with T) ? 
  26.  
  27. >thanks
  28. >Nasser
  29.  
  30. There shouldn't be anything preventing you from making all the
  31. parameterized types generic in a template.
  32.  
  33. You've tried, say,
  34.  
  35. template <class Container, class Item>
  36. class foo
  37. {
  38. };
  39.  
  40. and couldn't get it to work?   
  41. Your compiler vendor hasn't fully supported templates, I would think.
  42.  
  43.                     --Norm 
  44.  
  45.